﻿using System;
using System.Windows;
using System.Windows.Controls;
using Airborne.ScrumPoker.Model.TeamFoundation;
using Airborne.ScrumPoker.Module.Events;

namespace Airborne.ScrumPoker.Module.ProductOwner.Views
{
    /// <summary>
    /// Interaction logic for WorkItemDetailView.xaml
    /// </summary>
    public partial class WorkItemDetailView : UserControl, IWorkItemDetailsView
    {
        public WorkItemDetailView()
        {
            InitializeComponent();
        }

        #region IWorkItemDetailsView Members


        #region SaveWorkItem

        public event EventHandler<EventArgs> SaveWorkItem;

        private void RaiseSaveWorkItem()
        {
            EventArgs args = EventArgs.Empty;
            OnSaveWorkItem(args);
        }

        protected virtual void OnSaveWorkItem(EventArgs args)
        {
            EventHandler<EventArgs> handler = this.SaveWorkItem;
            if (handler != null)
            {
                handler(this, args);
            }
        }

        #endregion

        #region NextWorkItem
        public event EventHandler<EventArgs> NextWorkItem;

        private void RaiseNextWorkItem()
        {
            EventArgs args = EventArgs.Empty;
            OnNextWorkItem(args);
        }

        protected virtual void OnNextWorkItem(EventArgs args)
        {
            EventHandler<EventArgs> handler = this.NextWorkItem;
            if (handler != null)
            {
                handler(this, args);
            }
        }

        #endregion

        #region PreviousWorkItem
        public event EventHandler<EventArgs> PreviousWorkItem;

        private void RaisePreviousWorkItem()
        {
            EventArgs args = EventArgs.Empty;
            OnPreviousWorkItem(args);
        }

        protected virtual void OnPreviousWorkItem(EventArgs args)
        {
            EventHandler<EventArgs> handler = this.PreviousWorkItem;
            if (handler != null)
            {
                handler(this, args);
            }
        }

        #endregion

        public ITeamWorkItem WorkItem
        {
            get
            {
                return DataContext as ITeamWorkItem;
            }
            set
            {
                DataContext = value;
            }
        }

        #endregion

        private void buttonSaveWorkItemClick(object sender, RoutedEventArgs e)
        {
            RaiseSaveWorkItem();
        }

        private void buttonNextWorkItemClick(object sender, RoutedEventArgs e)
        {
            RaiseNextWorkItem();
        }

        private void buttonPreviousWorkItemClick(object sender, RoutedEventArgs e)
        {
            RaisePreviousWorkItem();
        }


    }
}
